package com.bruce.spring.http.service.controller;

import com.bruce.spring.http.api.Obj;
import jakarta.servlet.http.HttpServletRequest;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.service.annotation.PostExchange;

import java.util.List;
import java.util.Map;

/**
 * Created by bruce in 2025/7/10 22:31
 */
@RestController
public class H2cController {


    private static final Logger log = LoggerFactory.getLogger(H2cController.class);

    @PostExchange("/h2c")
    public String proto(HttpServletRequest request, @RequestBody Obj obj) {
        log.info("bytes:{}", obj);

        return request.getProtocol();
    }

    @ToString
    @Setter
    @Getter
    public static class Obj {
        private String name;
        private Integer age;
    }

}


